import React, { useEffect } from "react";
import { useNavigate } from "react-router-dom";

function WhileRouter({ children }) {
  function Newcap() {
    const navigate = useNavigate();
    const token = localStorage.getItem("token");
    useEffect(() => {
      if (!token) {
        navigate("/login");
      }
    }, [token]);
    return children;
  }
  return <Newcap></Newcap>;
}

export default WhileRouter;
